<?php

	$username 	= "alf";
	$sender		= "alf.redo@tin.it";
	$subject	= "sub\nject";
	$message	= "message";

	require_once("c4fmailer/ValidationSet.php");
	require_once("c4fmailer/NoEmptyValidator.php");
	require_once("c4fmailer/EmailFormatValidator.php");
	require_once("c4fmailer/EmailHeaderInjectionValidator.php");
	require_once("c4fmailer/c4fmailer.php");
	
	$validationset = new ValidationSet();
	$validationset->addValidator(new NoEmptyValidator("username",
													  $username,
													  "invalid username"));
	$validationset->addValidator(new EmailFormatValidator("sender",
													  	  $sender,
													  	  "invalid sender mail"));
	$validationset->addValidator(new NoEmptyValidator("subject",
													  $subject,
													  "invalid subject"));
	$validationset->addValidator(new EmailHeaderInjectionValidator("subject",
														  		   $subject,
														  		   "injection attempt detected in mail subject"));
	$validationset->addValidator(new NoEmptyValidator("message",
													  $message,
													  "invalid message"));													  		   													  	  
													  	  
	if ($validationset->performValidation()) {													  	  

		print "OK";
	} else {
		$error = $validationset->getErrors();
		print "<ul>\n";
		foreach ($error as $vError) {
			print "<li>".$vError->getErrorMessage()."</li>\n";
		}
		print "</ul>";
	}


?>